package creational.singleton.lazyman;

import creational.singleton.Singleton;

import java.io.Serializable;

/**
 * 懒汉单例,使用静态内部类实现,不需要加锁就解决了线程安全问题
 *
 * @author binbin
 * @since 2022/10/4 15:42
 */
public class LazyManSingleton4 implements Singleton, Serializable {


    private LazyManSingleton4() {
    }

    private static class Holder {
        private static final LazyManSingleton4 INSTANCE = new LazyManSingleton4();
    }

    public static LazyManSingleton4 getInstance() {
        return Holder.INSTANCE;
    }

    private Object readResolve() {
        return Holder.INSTANCE;
    }

}
